﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="TongHopBaoCao.ascx.cs"
    Inherits="Reports_TongHopBaoCao" %>
<asp:Label ID="lblError" runat="server" BackColor="White" BorderColor="White" Font-Italic="True"
    ForeColor="Red" Text="Label" Visible="False" Width="402px"></asp:Label>
    <table style="font-weight: bold">
        <tr>
            <td style="width: 139px; text-align: right">
                Danh sách báo cáo :</td>
            <td style="width: 242px">
                <asp:DropDownList ID="ddlBaocao" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlBaocao_SelectedIndexChanged"
                    Width="500px" DataTextField="ReportName" DataValueField="ReportId">
                </asp:DropDownList></td>
        </tr>
        <tr id="tinhChatAnChi" runat="server">
            <td style="width: 139px; height: 26px; text-align: right">
                <asp:Label ID="lblTinhChatAC" runat="server" Text="Tính chất ấn chỉ:"></asp:Label></td>
            <td style="width: 242px; height: 26px; text-align: left">
                <asp:DropDownList ID="ddlTinhChat" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlBaocao_SelectedIndexChanged"
                    Width="500px" TabIndex="1">
                    <asp:ListItem Value="1">Ấn chỉ thường</asp:ListItem>
                    <asp:ListItem Value="0">Ấn chỉ quan trọng</asp:ListItem>
                </asp:DropDownList></td>
        </tr>
        <tr id="dotPhatHanh" runat="server">
            <td style="width: 139px; height: 26px; text-align: right">
                <asp:Label ID="lblDPH" runat="server" Text="Đợt phát hành"></asp:Label></td>
            <td style="width: 242px; height: 26px; text-align: left">
                <asp:DropDownList ID="ddlDPH" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlBaocao_SelectedIndexChanged"
                    Width="500px" DataSourceID="SqlDataSource3" DataTextField="TenDot" DataValueField="id" TabIndex="2">
                </asp:DropDownList></td>
        </tr>
        <tr id="loaiAnChi" runat="server">
            <td style="width: 139px; height: 26px; text-align: right">
                <asp:Label ID="lblLoaiAC" runat="server" Text="Loại ấn chỉ:"></asp:Label></td>
            <td style="width: 242px; height: 26px; text-align: left">
                <asp:DropDownList ID="cboLoaiAnChi" runat="server" DataSourceID="SqlDataSource1"
                    DataTextField="TenAnChi" DataValueField="MaAnChi" Width="500px" TabIndex="3">
                </asp:DropDownList>
            </td>
        </tr>
        <tr id="tuNgay" runat="server">
            <td style="width: 139px; height: 26px; text-align: right">
                <asp:Label ID="lblTuNgay" runat="server" Text="Từ ngày:"></asp:Label></td>
            <td style="width: 242px; height: 26px; text-align: left">
                <asp:DropDownList ID="ddlDay" runat="server" Width="58px" TabIndex="4" OnSelectedIndexChanged="ddlDay_SelectedIndexChanged">
                </asp:DropDownList>
                <asp:DropDownList ID="ddlMonth" runat="server" AutoPostBack="True" Width="52px" TabIndex="5" OnSelectedIndexChanged="ddlMonth_SelectedIndexChanged">
                </asp:DropDownList>
                <asp:DropDownList ID="ddlYear" runat="server" AutoPostBack="True" Width="60px" TabIndex="6" OnSelectedIndexChanged="ddlYear_SelectedIndexChanged">
                </asp:DropDownList></td>
        </tr>
        <tr id="denNgay" runat="server">
            <td style="width: 139px; height: 26px; text-align: right">
                <strong>
                    <asp:Label ID="lblDenNgay" runat="server" Text="Đến ngày:"></asp:Label></strong></td>
            <td style="width: 242px; height: 26px; text-align: left">
                <asp:DropDownList ID="ddlDay1" runat="server" Width="58px" TabIndex="7">
                </asp:DropDownList>
                <asp:DropDownList ID="ddlMonth1" runat="server" AutoPostBack="True" Width="52px" TabIndex="8" OnSelectedIndexChanged="ddlMonth1_SelectedIndexChanged">
                </asp:DropDownList>
                <asp:DropDownList ID="ddlYear1" runat="server" AutoPostBack="True" Width="60px" TabIndex="9" OnSelectedIndexChanged="ddlYear1_SelectedIndexChanged">
                </asp:DropDownList></td>
        </tr>
        <tr id="khoDen" runat="server">
            <td style="width: 139px; height: 26px; text-align: right">
                <asp:Label ID="lblKhoDen" runat="server" Text="Kho đến:"></asp:Label></td>
            <td style="width: 242px; height: 26px; text-align: left">
                <asp:DropDownList ID="cboMaKho" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource2"
                    DataTextField="TenKho" DataValueField="MaKho" Width="500px" TabIndex="10">
                </asp:DropDownList>
            </td>
        </tr>
        <tr id="CN" runat="server">
            <td style="width: 139px; height: 26px; text-align: right">
                Chi nhánh</td>
            <td style="width: 242px; height: 26px; text-align: left">
                <asp:DropDownList ID="cboCN" runat="server" AutoPostBack="True"
                    DataTextField="TenKho" DataValueField="MaKho" Width="500px" DataSourceID="dsCN" OnSelectedIndexChanged="cboCN_SelectedIndexChanged" TabIndex="11">
                </asp:DropDownList></td>
        </tr>
        <tr id="pgd" runat="server">
            <td style="width: 139px; height: 26px; text-align: right">
                PGD:</td>
            <td style="width: 242px; height: 26px; text-align: left">
                <asp:DropDownList runat="server" ID="cboPGD" Width="500px" AutoPostBack="True" DataTextField="TenKho" DataValueField="MaKho" OnSelectedIndexChanged="cboPGD_SelectedIndexChanged" TabIndex="12"></asp:DropDownList>
            </td>
        </tr>
        <tr id="gdv" runat="server">
            <td style="width: 139px; height: 26px; text-align: right">
                GDV:</td>
            <td style="width: 242px; height: 26px; text-align: left">
                <asp:DropDownList runat="server" ID="cboGDV" Width="500px" DataTextField="TenKho" DataValueField="MaKho" TabIndex="13"></asp:DropDownList>
            </td>
        </tr>
        <tr>
            <td colspan="2" style="text-align: center">
                <asp:Button title="Kích nút này trước khi kích nút Xem báo cáo" ID="btnTH" runat="server" OnClick="btnTH_Click" Text="Tổng hợp báo cáo"
                    Width="127px" TabIndex="14" />
                <asp:Button ID="btnXem" runat="server" OnClick="btnXem_Click" Text="Xem báo cáo"
                    Width="109px" TabIndex="15" />
                <asp:Button ID="btnThoat" runat="server" OnClick="btnThoat_Click" Text="Thoát" Width="109px" TabIndex="16" /></td>
        </tr>
    </table>

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DBConnectionString %>"
    SelectCommand="/*&#13;&#10;if (@reportid<>'BC06' )&#13;&#10;BEGIN&#13;&#10;iF(@dotPhatHanh=0)&#13;&#10;Select distinct MaAnChi,MaAnChi + '-' + TenAnChi+ case(AnChiMau) when 1 then N' (mẫu)' when 0 then '' end [TenAnChi]  from MaAnChi  where MaLoaiAnChi=@maloaianchi &#13;&#10;order by MaAnChi&#13;&#10;else&#13;&#10;Select distinct Ma as MaAnChi,MaAnChi + '-' +TenAnChi+ case(AnChiMau) when 1 then N' (mẫu)' when 0 then '' end [TenAnChi]  from MaAnChi  where MaLoaiAnChi=@maloaianchi and madotphathanh=@dotphathanh &#13;&#10;order by Ma&#13;&#10;END&#13;&#10;ELSE  &#13;&#10;BEGIN&#13;&#10;iF(@dotPhatHanh=0)&#13;&#10;Select distinct MaAnChi,MaAnChi + '-' +TenAnChi+ case(AnChiMau) when 1 then N' (mẫu)' when 0 then '' end [TenAnChi]  from MaAnChi  where MaLoaiAnChi=@maloaianchi &#13;&#10;order by MaAnChi&#13;&#10;else&#13;&#10;Select distinct Ma as MaAnChi,MaAnChi + '-' +TenAnChi+ case(AnChiMau) when 1 then N' (mẫu)' when 0 then '' end [TenAnChi]  from MaAnChi  where MaLoaiAnChi=@maloaianchi and madotphathanh=@dotphathanh&#13;&#10;order by Ma&#13;&#10;END&#13;&#10;*/&#13;&#10;&#13;&#10;&#13;&#10;iF(@dotPhatHanh=0)&#13;&#10;Select distinct MaAnChi,MaAnChi + '-' + TenNhom as TenAnChi from MaAnChi  where MaLoaiAnChi=@maloaianchi and anchimau=0&#13;&#10;order by MaAnChi&#13;&#10;else&#13;&#10;Select distinct MaAnChi,MaAnChi + '-' + TenNhom as TenAnChi from MaAnChi  where MaLoaiAnChi=@maloaianchi and madotphathanh=@dotphathanh and anchimau=0&#13;&#10;order by MaAnChi"
    ProviderName="<%$ ConnectionStrings:DBConnectionString.ProviderName %>">
    <SelectParameters>
        <asp:ControlParameter ControlID="ddlTinhChat" Name="maloaianchi" PropertyName="SelectedValue" />
        <asp:ControlParameter ControlID="ddlDPH" Name="dotphathanh" PropertyName="SelectedValue" />
        <asp:ControlParameter ControlID="ddlBaocao" Name="reportid" PropertyName="SelectedValue" />
    </SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:DBConnectionString %>"
    ProviderName="<%$ ConnectionStrings:DBConnectionString.ProviderName %>" SelectCommand="SELECT '0' as MaKho,N'Tất cả' as TenKho FROM MAKHO&#13;&#10;union&#13;&#10;SELECT '00' as MaKho,N'NHÀ IN' as TenKho FROM MAKHO&#13;&#10;UNION&#13;&#10;SELECT MaKho,MaKho + '-'+TenKho as TenKho FROM MAKHO">
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:DBConnectionString %>"
    ProviderName="<%$ ConnectionStrings:DBConnectionString.ProviderName %>" SelectCommand="select '0' as  id,N'Tất cả các đợt' as TenDot from DotPhatHanh &#13;&#10;union &#13;&#10;select id,TenDot from DotPhatHanh ">
</asp:SqlDataSource>
<asp:SqlDataSource ID="dsCN" runat="server" ConnectionString="<%$ ConnectionStrings:DBConnectionString %>"
    ProviderName="<%$ ConnectionStrings:DBConnectionString.ProviderName %>" SelectCommand="select makho, makho+' - '+TenKho as TenKho from makho where capquanly=2 and makho <>'000'"></asp:SqlDataSource><asp:SqlDataSource ID="dsPGD" runat="server" ConnectionString="<%$ ConnectionStrings:DBConnectionString %>"
    ProviderName="<%$ ConnectionStrings:DBConnectionString.ProviderName %>"></asp:SqlDataSource>
<asp:SqlDataSource ID="dsGDV" runat="server" ConnectionString="<%$ ConnectionStrings:DBConnectionString %>"
    ProviderName="<%$ ConnectionStrings:DBConnectionString.ProviderName %>" SelectCommand="MaKho_GetAllGDV_By_MaPGD"
    SelectCommandType="StoredProcedure">
    <SelectParameters>
        <asp:ControlParameter ControlID="cboPGD" Name="maKho" PropertyName="SelectedValue"
            Type="String" />
    </SelectParameters>
</asp:SqlDataSource>
